#include "ExpAST.h"
#include "Globe.h"
#include <iostream>
#include "parser.h"
#include "Globe.h"
#pragma warning(disable:4267)
using std::cout;
using std::endl;
unique_ptr<BaseExpAST> parser::parseXorExp()
{
    unique_ptr<BaseExpAST>l = parseAndExp();
    while (this->lexer->next_token() == TOK::XOR)
    {
        this->lexer->match(TOK::XOR);
        unique_ptr<XorAST>t(new XorAST);
        t->exp1 = std::move(l);
        t->exp2 = parseAndExp();
        l = std::move(t);
    }
    return l;
}
void XorAST::Dump() const
{
    cout << "{\"type\":\"Xor\",\"exp1\":";
    this->exp1->Dump();
    cout << ",\"exp2\":";
    this->exp2->Dump();
    cout << "}";
}


bool XorAST::is_lval() const
{
    return false;
}

void XorAST::Analyze() const
{
    this->exp2->Analyze();
    GENASM(cmd_code::PUSH, CVR(EAX), cmd_val());
    this->exp1->Analyze();
    GENASM(cmd_code::POP, CVR(EDX), cmd_val());
    GENASM(cmd_code::XOR, CVR(EAX), CVR(EDX));
}
